# -*- coding: utf-8 -*-
   
from flask import Flask
import os
import logging
from logging import Formatter
from logging.handlers import TimedRotatingFileHandler

app = Flask(__name__)
profile = os.environ.get('DONATO_PROFILE', '')
app.config.from_object('config.' + profile + 'Config')

logger = logging.getLogger('Donato_bot')

def init_logger():
  logging.basicConfig(format = '%(asctime)s %(module)s %(levelname)s: %(message)s ')
  logging.getLogger("itchat").setLevel(logging.INFO)
  logger = logging.getLogger('Donato_bot')
  handler = TimedRotatingFileHandler(app.config['BOT_LOG_FILE'], when="midnight", encoding = "utf-8")
  handler.suffix = '%Y-%m-%d'
  handler.setFormatter(Formatter(
  '%(asctime)s %(module)s %(levelname)s: %(message)s '
  '[in %(pathname)s:%(lineno)d]'
  ))
  logger.addHandler(handler)
  logger.setLevel(logging.INFO)

init_logger()
